<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="cn.myschool.service.SubjectService" %>
<%@ page import="cn.myschool.entity.Subject" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.myschool.pojo.Subject2" %>
<%@ page import="cn.myschool.util.StrUtil" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script src="js/jquery.js"></script>
    <script src="js/js.js"></script>

</head>
<body>

<%@include file="checkLogin.jsp" %>

<!--主体内容-->
<section class="publicMian ">

    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>课程管理</span>
        </div>
        <%
            String subname=request.getParameter("subjectname");
            subname=subname== null?"":subname;
            int pageNo= StrUtil.toInt(request.getParameter("pageNo"),1);
        %>
        <div class="search">
            <form action="subject.jsp" method="get" id="seachForm">
                <input type="hidden" name="pageNo" id="pageNo" value="<%=pageNo%>"/>
                <span>课程名称：</span>
                <input type="text" name="subjectname" value="<%=subname%>" placeholder="请输入课程名称"/>
                <input type="submit" value="查询"/>
                <a href="subjectAdd.jsp">添加</a>
            </form>
        </div>
        <!--供应商操作表格-->
        <table class="providerTable" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="10%">编号</th>
                <th width="20%">课程名</th>
                <th width="10%">课时</th>
                <th width="10%">年级</th>

                <th width="30%">操作</th>
            </tr>
            <%
                List<Subject2> datas = SubjectService.ME.paging(pageNo, 10,subname);
                for (Subject2 s : datas) {
            %>
            <tr>
                <td><%=s.getId()%>
                </td>
                <td><%=s.getSubjectname()%>
                </td>
                <td><%=s.getClasshour()%>
                </td>
                <td><%--<%=s.getGradeid()%>--%>
                    <%=s.getGradeName()%>
                </td>

                <td>
                    <%--<a href="providerView.html"><img src="img/read.png" alt="查看" title="查看"/></a>--%>
                    <a href="subjectUpdate.jsp?id=<%=s.getId()%>"><img src="img/xiugai.png" alt="修改" title="修改"/></a>
                    <a href="delSubject.jsp?id=<%=s.getId()%>" onclick="return window.confirm('真的要删除这个课程?')"><img
                            src="img/schu.png" alt="删除" title="删除"/></a>
                    <%--<a href="#" class="removeProvider"><img src="img/schu.png" alt="删除" title="删除"/></a>--%>
                </td>
            </tr>
            <%}%>
        </table>
        <p align="center" class="pager">
            <a id="prev" href="#" data-page="1">上一页</a>
            <%
                if(pageNo>1){
            %>
            <a id="prev" href="#" data-page="<%=pageNo-1%>">上一页</a>
            <%}%>
            <a href="#" id="next" data-page="<%=pageNo+1%>">下一页</a>

            <a href="#" id="next" data-page="<%=pageNo+1%>">最后一页</a>
            <%--<%
                if(pageNo>1){
            %>
            <a href="subject.jsp?pageNo=<%=pageNo-1%>&subjectname=<%=subname%>">上一页</a>
            <%}%>
            <a href="subject.jsp?pageNo=<%=pageNo+1%>&subjectname=<%=subname%>">下一页</a>--%>
        </p>
    </div>
</section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeProv">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该供应商吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>

<script>
    $(function () {
        $("form#seachForm :submit").click(function () {
            $("#pageNo").val(1);//每次搜索，页号从1开始
            return true;
        });
       $(".pager a").click(function () {
           let pageNo= $(this).data("page");
           //alert(pageNo);
           //$(this).attr("data-page");
            $("#pageNo").val(pageNo);
            $("form#seachForm").submit();//手工提交表单
           return false;//让a 链接失效
       });
    });
</script>

</body>
</html>
